<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/conformanceFunction.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:reg="http://xbrl.org/2008/registry"
  xmlns:fcn="http://xbrl.org/2008/function"
  xmlns:cfcn="http://xbrl.org/2008/conformance/function"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:t="http://xbrl.org/formula/conformance/example" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  http://xbrl.org/2008/conformance ../schemas/conformance.xsd
  http://xbrl.org/2008/conformance/function ../schemas/conformanceFunction.xsd
  ">
  <owners>
    <reg:owner id="herm">
      <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
      <reg:email>fischer@markv.com</reg:email>
     <reg:assumedOwnership moment="2008-02-06T12:55:00" />
    </reg:owner>
  </owners>

  <number>90308</number>

  <name>xfi:fact-explicit-dimension-value</name>

  <documentation>
  </documentation>

  <reference
    xlink:type="simple"
    xlink:href="90309 xfi.fact-explicit-dimension-value function.xml">
    function definition  
  </reference>

  <variation id="V-01">
    <name>Location dimension for Mount Kilimanjaro</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V01" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V01">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Mount Kilimanjaro'], 
          QName('http://xbrl.org/formula/conformance/example','t:Location')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:Tanzania')
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-01a">
    <name>Location default dimension for Vinson Massif</name>
    <documentation>
      <xhtml:p>
         Mt Vinson uses the Antarctica default dimension, so although it is not physically reported in the context, it is virtually reported due to the default for the dimension.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V01a" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V01a">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Vinson Massif'], 
          QName('http://xbrl.org/formula/conformance/example','t:Location')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:Antarctica')
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-02">
   <name>Location dimension for Peak concept Aurora Borealis (whose context lacks the location dimension)</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V02" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V02">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Aurora Borealis'], 
          QName('http://xbrl.org/formula/conformance/example','t:Location')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:Antarctica')
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-03">
   <name>Location dimension for AtmosphericPhenomenon concept with open hypercube 'leaks' global dimension-default value
   </name>
    <documentation>
      <xhtml:p>
        Location dimension for AtmosphericPhenomenon concept Aurora Borealis (whose hypercube lacks the location dimension): 
        The AtmosphereicPhenomenon primary item has an open hypercube.  (It isn't supposed to have a location dimension, but
        as this variation was originally written, because the hypercube is open, and the location dimension-default is global, that
        causes the location dimension to be valid and the default value applies to facts of this primary item despite it being 'unwanted'.  
        That is 'fixed' in variation V-03a.)
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V03" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V03">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:AtmosphericPhenomenon[./text() eq 'Aurora Borealis'], 
          QName('http://xbrl.org/formula/conformance/example','t:Location')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:Antarctica')
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-03a">
   <name>Location dimension for AtmosphericPhenomenon, closed hypercube, no value for absent dimension
   </name>
    <documentation>
      <xhtml:p>
        Demonstrates that the default value is reported even when it is not dimensionally valid for the primary item.
        Same as V-03 but regardless that the Atmospheric Phenomenon primary item now has a closed hypercube (by a higher priority arc which
        overrides with closed=true) so that the location dimension is not dimensionally valid or expected, despite being a
        global default.  However this test case assures that the unwanted default dimension value is reported for facts of this primary item.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <linkbase xlink:type="simple" xlink:href="close-the-atmosphere-definition.xml"/>
      <instance readMeFirst="true" id="V03a" xlink:type="simple" xlink:href="closed-atmosphere-instance1.xml"/>
      <cfcn:call file="V03a">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:AtmosphericPhenomenon[./text() eq 'Aurora Borealis'], 
          QName('http://xbrl.org/formula/conformance/example','t:Location')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:Antarctica')
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-04">
    <name>Error of concept argument which is not a dimension</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V04" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V04">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Mount Everest'], 
          QName('http://xbrl.org/formula/conformance/example','t:Mars')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidExplicitDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-05">
    <name>Error of non-XBRL element argument as dimension argument</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V05" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V05">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Mount Everest'], 
          QName('http://xbrl.org/formula/conformance/example','t:nonXbrlElement')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidExplicitDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-06">
    <name>Raises an error for an attribute declaration argument</name>
    <documentation>
      <xhtml:p>
        Tests that error is detected when the concept name argument declares an attribute.
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V06" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V06">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Mount Everest'], 
          QName('http://xbrl.org/formula/conformance/example','t:anAttribute')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidExplicitDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-07">
    <name>Raises an error for an xbrli namespace&apos;ed argument</name>
    <documentation>
      <xhtml:p>
        Tests that error is detected when the concept qname is xbrli:item
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="fact-explicit-dimension-value.xsd"/>
      <linkbase xlink:type="simple" xlink:href="fact-explicit-dimension-value-definition.xml"/>
      <instance readMeFirst="true" id="V07" xlink:type="simple" xlink:href="fact-explicit-dimension-value-instance1.xml"/>
      <cfcn:call file="V07">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:Peak[./text() eq 'Mount Everest'], 
          QName('http://xbrl.org/formula/conformance/example','xbrli:item')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xfie:invalidExplicitDimensionQName</error>
    </outputs>
  </variation>

  <variation id="V-08">
   <name>Dimension can be located in either segment or scenario, for this variation appears in the segment, to test that function is looking in only desired location for value.</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="bi-locational-dim-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="bi-locational-dim-definition.xml"/>
      <instance readMeFirst="true" id="V08" xlink:type="simple" xlink:href="bi-locational-seg-explicit-instance.xml"/>
      <cfcn:call file="V08">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:PriItem1[1], 
          QName('http://xbrl.org/formula/conformance/example','t:ExplDim1')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:ExplDim1Mbr1')
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-09">
   <name>Dimension can be located in either segment or scenario but for this variation appears in the scenario instead of segment, to test that function is looking in only desired location for value.</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
     </documentation>
      
    <inputs>
      <schema xlink:type="simple" xlink:href="bi-locational-dim-concepts.xsd"/>
      <linkbase xlink:type="simple" xlink:href="bi-locational-dim-definition.xml"/>
      <instance readMeFirst="true" id="V09" xlink:type="simple" xlink:href="bi-locational-scen-explicit-instance.xml"/>
      <cfcn:call file="V09">
        xfi:fact-explicit-dimension-value(
          /xbrli:xbrl/t:PriItem1[1], 
          QName('http://xbrl.org/formula/conformance/example','t:ExplDim1')
          )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of xs:QName? and
         count( $result ) eq 1 and
         $result eq QName('http://xbrl.org/formula/conformance/example','t:ExplDim1Mbr1')
      </cfcn:test>
    </outputs>
  </variation>

  <revisions>
    <reg:revision on="2008-02-06T12:55:00" by="herm">
      <xhtml:p>
        Created the test case.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-03-16T08:30:00" by="herm">
      <xhtml:p>
        Added variations for bi-locational dimension with value in desired and opposite locations.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-05-22T08:30:00" by="herm">
      <xhtml:p>
        Added variation v-01a for default dimension value.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-09-01T00:00:00" by="herm">
      <xhtml:p>
        Made the function segment/scenario agnostic, renamed without segment/scenario in name.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2008-11-16T00:00:00" by="herm">
      <xhtml:p>
        Changed V-03 to empty result.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2010-12-28T00:00:00" by="herm">
      <xhtml:p>
        Updated preceding change, to correspond with 2009 base spec WG resolving applicability of dimension
        defaults to primary items (bug 343).  In V-03 the primary item has an open hypercube, so the location dimension
        is allowed, and has a default value, which is applied to V-03's primary item (despite being silly
        for the example).  A new variation is added, V-03a, closing that hypercube, so the unwanted
        location dimension is not allowed and does not show up as a default member value.  Thanks to
        IHR for identifying this issue and helping.
      </xhtml:p>
    </reg:revision>
    <reg:revision on="2011-03-01T16:00:00" by="herm">
      <xhtml:p>
        Changed v-03a to report the default value even when a closed hypercube does not allow it.  Accompanies function change to
        clarify that dimension default values are reported for a dimension without respect to such a default value's
        validity for a given primary item.
      </xhtml:p>
    </reg:revision>
  </revisions>

</testcase>
